package pattern5.leifeng;

/**
 * 简单工厂和工厂方法的调用
 *
 * @author wdl
 */
public class FactoryPattern {
    public static void main(String[] args) {
        //通过简单工厂实现
        LeiFeng stu1 = SimpleFactory.createLeiFeng("学雷锋的大学生");
        stu1.sweep();
        LeiFeng stu2 = SimpleFactory.createLeiFeng("学雷锋的大学生");
        stu2.wash();
        LeiFeng stu3 = SimpleFactory.createLeiFeng("学雷锋的大学生");
        stu3.buyRice();

        //通过工厂方法实现
        IFactory factory = new VolunteerFactory();
        LeiFeng volunteer1 = factory.createLeifeng();
        volunteer1.sweep();
        LeiFeng volunteer2 = factory.createLeifeng();
        volunteer2.wash();
        LeiFeng volunteer3 = factory.createLeifeng();
        volunteer3.buyRice();

    }
}
